import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
// ===================================================================== Declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const Page = $Lazy.load(()=>import('#tp/page/page-container'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// 标本拆分状态
		splitStatus: [{ name:'停止拆分', value:'-1' }],
		// 搜索表单列表
		forms : [
			{ label: '原条码',		name: 'old_spec_code' },
			{ label: '创建时间',		names: ['start_date','end_date'], 	type:'date-range', 	loading:true },
		],
	}
	
	model = {}
	query = { split_status: -1 }
	
	componentDidMount(){
		if(window.isInit){
			this.fetch()
		}
	}
	
	// paging
	fetch = () => $fn.fetch.call(this,'spec-split/index')
	
	// 表单
	cols = [
		{ title: '标本类型', 	dataIndex: 'spec_type_name', 	width:100 },
		{ title: '原条码', 		dataIndex: 'new_spec_code', 	...$fn.table.spec_code },
		{ title: '新条码', 		dataIndex: 'old_spec_code', 	...$fn.table.spec_code },
		{ title: '说明', 		dataIndex: 'description', 		width:180 },
		{ title: '创建时间', 	dataIndex: 'created_at',  		...$fn.table.time},
		{ title: '使用状态', 	dataIndex: 'split_status', 		width:100,	render: text => $fn.getState(this.state.enabled,text) },
	]
	
	render(){
		return (
			<Page title='禁止拆分'>
				{/* 搜索 */}
				{ SearchForm.call(this) }
				{/* 表格 */}
				{ Table.call(this, {isInit: window.isInit}) }
			</Page>
		)
	}
}

export default Index